Skip to content

fix: use Tree.Root.String() for JS/CSS extraction to avoid html/template escaping#12

Merged
jonathanpopham merged 1 commit intomainfrom
fix/render-js-css-escaping
Feb 28, 2026
Merged

fix: use Tree.Root.String() for JS/CSS extraction to avoid html/template escaping#12
jonathanpopham merged 1 commit intomainfrom
fix/render-js-css-escaping

Conversation

@jonathanpopham
Copy link
Contributor

Fixes the remaining graph rendering issue from #10.

Summary

RenderJS() and RenderCSS() were running _main.js and _styles.css through html/template's Execute(), which HTML-escapes < to &lt;. This broke every for-loop and comparison in main.js (8 instances), causing a JS syntax error that killed the entire script before D3 graph rendering code could execute.

Same root cause as the template.HTMLtemplate.JS fix merged in #11: the text/templatehtml/template migration in 8f1470b.

Fix

Use t.Tree.Root.String() instead of t.Execute() to return the raw template source without html/template's context-aware escaping. These files are static assets with no Go template directives.

Verified locally

  • node --check main.js passes (was failing with Unexpected token ';' before)
  • D3 force graph renders correctly in browser
  • All existing tests pass

…ate escaping

RenderJS() and RenderCSS() were running static assets through
html/template's Execute(), which HTML-escapes < to &lt; in the output.
This broke all for-loops and comparisons in main.js (8 instances),
causing a syntax error that prevented all D3 graphs from rendering.

Same root cause as the template.HTML → template.JS fix: the
text/template → html/template migration in 8f1470b.
@jonathanpopham jonathanpopham merged commit 1e08478 into main Feb 28, 2026
1 check passed
@jonathanpopham jonathanpopham deleted the fix/render-js-css-escaping branch February 28, 2026 03:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant